/**
 * Alibaba.com.cn Inc.
 * Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.starlink.controller;

import com.starlink.common.annotation.client.weixin.*;
import com.starlink.service.WechatPayService;
import com.starlink.utils.FastJsonUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhanghong
 * @version AdminXcxGoodsOrderController.java, v 0.1 2022/3/19 14:37 下午 AdminXcxGoodsOrderController Exp $$
 */
@Slf4j
@RestController
@RequestMapping("/wechat/pay")
@Api(value = "微信支付模块", tags = {"微信支付模块"})
public class WechatPayController extends BaseController {

    @Autowired
    private WechatPayService wechatPayService;

    @ApiOperation(value = "微信支付回调通知", httpMethod = "POST")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/pay/notify")
    public WeixinPayNotifyRes wxPayNotify(@RequestBody WeixinPayNotifyReq req) {
        log.info("wxPayNotify 微信支付通知: {}", FastJsonUtils.toJSONString(req));
        return wechatPayService.wxPayNotify(req);
    }

    @ApiOperation(value = "微信退款回调通知", httpMethod = "POST")
    @ApiResponses(value = {@ApiResponse(code = 200, message = "success")})
    @PostMapping("/refund/notify")
    public WeixinRefundNotifyRes wxRefundNotify(@RequestBody WeixinRefundNotifyReq req) {
        log.info("wxRefundNotify 微信退款通知: {}", FastJsonUtils.toJSONString(req));
        return wechatPayService.wxRefundNotify(req);
    }
}
